Palindrome Linked List
Hard
Question
Given the head of a linked list of integers, return True
if it's a palindrome, otherwise return False
.
A linked list is a palindrome if it sequence of nodes reads the same forwards and backwards.
Input: head = [4 -> 7 -> 7 -> 4]
Output: True
Input: head = [4 -> 7 -> 7]
Output: False
Follow up: Could you solve this in O(n) time and O(1) space?
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
Which of these linked lists is *not* a palindrome?
[]
[7 -> 11 -> 11]
[1 -> 2 -> 3 -> 2 -> 1]
[1 -> 2 -> 3 -> 3 -> 2 -> 1]
All test cases pass! 🎉
Time limit exceeded
InputExpected OutputActual Output
Standard OutputScroll down...
Login or signup to save your code.
Uh oh... looks like you don't yet have access.
Not sure what this unlocks? Check out a free pattern section.